#include <error_process.hpp>

static double divide(double a, double b)
{
    if (b == 0) {
        throw "输入除数为0";
    }
    return a/b;
}

static double divide_new(double a, double b)
{
    if (b == 0) {
        throw "";
    }
    return a/b;
} 

void exec_divide()
{
    double param1, param2;
    cout << "请输入被除数" << endl;
    cin >> param1;
    cout << "请输入除数" << endl;
    cin >> param2;

    try {
        double result = divide(param1, param2);
        cout << "除法结果为：" << result << endl;
    }
    catch (const char* msg){
        cerr << "Error: " << msg << endl;
    }
}

void exec_divide_by_custom_error()
{

}

class param_invalid_exception : public exception {
    private:
        string message;
    public:
        param_invalid_exception(string &msg) : message(msg) {};
    
        const char* what() const noexcept override {
            return message.c_str();
        }

};


